#include "bilibili.h"
#include "bilibili_gui.h"
#include "../sys/app_contorller.h"
#include "../../common.h"

#define WEATHER_PAGE_SIZE1 2

int clock_page1 = 0;  

void bilibili_init(void)
{
}

void bilibili_process(AppController *sys,
                          const Imu_Action *act_info)
{    
    lv_scr_load_anim_t anim_type1 = LV_SCR_LOAD_ANIM_NONE;
    if (RETURN == act_info->active)
    {
        sys->app_exit(); // 退出APP
        return;
    } 
    if (TURN_RIGHT == act_info->active)
    {
        // 切换界面时，变相强制更新

        anim_type1 = LV_SCR_LOAD_ANIM_MOVE_RIGHT;
        clock_page1 = (clock_page1 + 1) % WEATHER_PAGE_SIZE1;
    }
    else if (TURN_LEFT == act_info->active)
    {
        // 切换界面时，变相强制更新
     
        anim_type1 = LV_SCR_LOAD_ANIM_MOVE_LEFT;
        // 以下等效与 clock_page = (clock_page + WEATHER_PAGE_SIZE - 1) % WEATHER_PAGE_SIZE;
        // +3为了不让数据溢出成负数，而导致取模逻辑错误
        clock_page1 = (clock_page1 + WEATHER_PAGE_SIZE1 - 1) % WEATHER_PAGE_SIZE1;
    }

    if (0 == clock_page1) // 更新天气
    {
       
    }

    delay(300);
}

void bilibili_exit_callback(void)
{
}

void bilibili_event_notification(APP_EVENT event)
{
}

APP_OBJ bilibili_app = {"Media", &app_bilibili, bilibili_init,
                     bilibili_process, bilibili_exit_callback,
                     bilibili_event_notification};
